// Problem: P2097 资料分发1
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P2097
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<vector>
using namespace std;

int n,m,ans=0;
vector<int> f[100005];
int vis[100005]={0};

void dfs(int x)
{
	for(int i=0;i<f[x].size();++i)
	{
		if(vis[f[x][i]]==0)
		{
			vis[f[x][i]]=1;
			dfs(f[x][i]);
		}
	}
}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		int p,q;
		scanf("%d %d",&p,&q);
		f[p].push_back(q);
		f[q].push_back(p);
	}
	for(int x=1;x<=n;++x)
	{
		if(vis[x]==0)
		{
			++ans;
			vis[x]=1;
			dfs(x);
		}
	}
	cout<<ans;
	return 0;
}